import { formatDate } from '@src/assets/js/tool'
import { CaseSchema } from '@src/components/schema/caseSchema'
import { ColumnsType } from 'antd/es/table'
import style from './index.module.less'
import Serieno from '@src/pages/admin/components/serieno'

export function getColumn (): ColumnsType<CaseSchema> {
  const columns: ColumnsType<CaseSchema> = [
    {
      title: '序号',
      dataIndex: 'orderno',
      key: 'orderno',
      width: 80
    },
    {
      title: '案号',
      dataIndex: 'caseno_desc',
      key: 'caseno_desc',
      render: (v: string, l: CaseSchema) => {
        return (
          <span>
            <span>{v}</span>
            <Serieno data={l} />
          </span>
        )
      }
    },
    {
      title: '申请人',
      dataIndex: 'applicant_name',
      key: 'applicant_name'
    },
    {
      title: '受理秘书',
      dataIndex: 'accepter',
      key: 'accepter'
    },
    {
      title: '办案秘书',
      dataIndex: 'processer',
      key: 'processer'
    },
    {
      title: '仲裁程序',
      dataIndex: 'procedure',
      key: 'procedure',
      render: (v: string, l: CaseSchema) => {
        if (l.fast_closure === '是') {
          return <span>{v}<span className={style.fast}>（快）</span></span>
        }
        return v
      }
    },
    {
      title: '收案时间',
      dataIndex: 'accept_datetime',
      key: 'accept_datetime',
      render: (v: number) => {
        if (typeof v === 'number') {
          return formatDate(v, 'YY.MM.DD')
        }
      }
    },
    {
      title: '立案时间',
      dataIndex: 'docket_datetime',
      key: 'docket_datetime',
      render: (v: number) => {
        if (typeof v === 'number') {
          return formatDate(v, 'YY.MM.DD')
        }
      }
    },
    {
      title: '组庭时间',
      dataIndex: 'arbitrator_assign_datetime',
      key: 'arbitrator_assign_datetime',
      render: (v: number) => {
        if (typeof v === 'number') {
          return formatDate(v, 'YY.MM.DD')
        }
      }
    },
    {
      title: '结案时间',
      dataIndex: 'closure_datetime',
      key: 'closure_datetime',
      render: (v: number) => {
        if (typeof v === 'number') {
          return formatDate(v, 'YY.MM.DD')
        }
      }
    },
    {
      title: '结案类型',
      dataIndex: 'closure_type',
      key: 'closure_type'
    },
    {
      title: '受理分',
      dataIndex: 'accepter_score',
      key: 'accepter_score',
      render: (v: number) => {
        if (typeof v === 'number') {
          return v.toFixed(2)
        }
      }
    },
    {
      title: '办案分',
      dataIndex: 'processer_score',
      key: 'processer_score',
      render: (v: number) => {
        if (typeof v === 'number') {
          return v.toFixed(2)
        }
      }
    }
  ]
  return columns
}
